import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsEnum, IsNotEmpty, IsOptional, IsString, Matches } from 'class-validator';
import { SendMineVcodeType, SendVcodeType } from "common/utils/data";
import { MOBILE_REGEXP } from "common/utils/regexp";

export class SendEmailVcodeDto {
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  email: string;

  @IsNotEmpty()
  @ApiProperty({
    enum: SendVcodeType,
  })
  @IsEnum(SendVcodeType)
  type: SendVcodeType;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  vcodeKey?: string;

}

export class SendMobileVcodeDto {
  @IsNotEmpty()
  @ApiProperty()
  @Matches(MOBILE_REGEXP)
  mobile: string;

  @IsNotEmpty()
  @ApiProperty({
    enum: SendVcodeType,
  })
  @IsEnum(SendVcodeType)
  type: SendVcodeType;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  vcodeKey?: string;

}

export class SendMineMobileVcodeDto {
  @IsNotEmpty()
  @ApiProperty({
    enum: SendMineVcodeType,
  })
  @IsEnum(SendMineVcodeType)
  type: SendMineVcodeType;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  vcodeKey?: string;
}
